package logic

import (
	"context"
	"person/api/internal/svc"
	"person/api/internal/types"
	"person/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDetailLogic {
	return &UserDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserDetailLogic) UserDetail(req *types.UserDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	date, err := l.svcCtx.UserRpc.UserDetail(l.ctx, &userrpc.UserDetailRequest{
		UserId: req.UserId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "ok",
		Code:    200,
		Data:    date,
	}, nil
}
